package com.jeln.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;


//配置类
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {

    //重写addInterceptors方法，要过滤/admin/**（/admin下面的所有资源），排除/admin和/admin下面的login页面
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/admin/**")
                .excludePathPatterns("/admin")
                .excludePathPatterns("/admin/login");
    }
}
